package com.situation.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
public class RespUtil {

    private Integer code;
    private String msg;
    private Object data;

    public RespUtil setData(Object data) {
        this.data = data;
        return this;
    }

    public RespUtil(StatusEnum statusEnum) {
        this.code = statusEnum.getCode();
        this.msg = statusEnum.getMsg();
    }

    public static RespUtil ok() {
        return new RespUtil(StatusEnum.OK);
    }

    /**
     * 500
     * @return
     */
    public static RespUtil fail() {
        return new RespUtil(StatusEnum.FAIL);
    }

    /**
     * 404
     * @return
     */
    public static RespUtil notFound() {
        return new RespUtil(StatusEnum.NOT_FOUND);
    }

    /**
     * 403
     * @return
     */
    public static RespUtil forBidden() {
        return new RespUtil(StatusEnum.FORBIDDEN);
    }
    /**
     * 501
     * @return
     */
    public static RespUtil account() {
        return new RespUtil(StatusEnum.ACCOUNT);
    }

    /**
     * 502
     * @return
     */
    public static RespUtil unknownAccount() {
        return new RespUtil(StatusEnum.UnknownAccount);
    }

    /**
     * 账号锁定503
     * @return
     */
    public static RespUtil lockedAccount() {
        return new RespUtil(StatusEnum.LockedAccount);
    }

    /**
     * 504 密码错误
     * @return
     */
     public static RespUtil incorrectCredentials() {
        return new RespUtil(StatusEnum.IncorrectCredentials);
    }

    /**
     * 没有权限
     * @return
     */
     public static RespUtil unauthorized() {
        return new RespUtil(StatusEnum.UNAUTHORIZED);
    }


}
